1. Field of the Invention
The present invention relates to a program processing system and its processing method. More particularly, this invention is concerned with a system for processing a database processing application program created by embedding a database processing program written in SQL or other database processing language into a program written in COBOL, FORTRAN, or another general-purpose programming language.
2. Description of the Related Art
FIGS. 1 and 2 are flowcharts showing the source program compilation procedure in a conventional database processing system. FIG. 3 shows a compilation result of a source program. FIG. 4 is a flowchart showing the operation of the database processing request procedure required for executing a database processing program including compiled procedures. FIG. 5 shows an example of a database processing program used for explanation.
A general-purpose programming language used to write a database processing program shall be X, and a database processing language, Y. In FIG. 5, 1 denotes a database processing program. 2 is a portion of the database processing program which is written in X, and 3, a portion written in Y. Herein, the Y portion starts and ends, for easy understanding, with "exec sq1" and "end exec". In this form, the portion is embedded in a program written in X. The program shown in FIG. 5 retrieves a maximum income from a table s containing data under the condition that the income does not exceed 100, assigns the value to a variable, "maxincome", then outputs the result to a terminal. Then, the program retrieves a minimum income from the table s containing data under the condition that the income exceeds 200, assigns the value to a variable, "minincome", then outputs the result to the terminal.
When a source code of a database processing program is entered, the program is compiled according to the operation shown in FIGS. 1 and 2. First, at a step 36, the operation starts. At a step 37, it is determined whether a source file to be compiled still resides. If it resides, processing A shown in FIG. 2 is executed at a step 38.
In the processing A, the operation starts at a step 45. It is determined at a step 46 whether any element to be processed still resides. If it does not reside, the A returns to the caller at a step 55. If an element resides, it is read at a step 47. At a step 48, it is determined whether the read element is "exec sq1". If it is not "exec sq1", the element is passed to a general X compiler, then compiled as an X program. Then, the operation returns to the step 46.
If the read element is "exec sq1", the subsequent elements ending with "end exec" forms the Y program. This portion is designated as P at a step 50. At a step 51, the P is compiled to create an actual database processing procedure. Registered procedures are assigned mutually-different identifiers I so that they can be identified. The system, therefore, has a counter for generating the identifiers. Every time a procedure is created, the counter is incremented by 1 at a step 52 to provide a different identifier. The identifier is represented as I. At a step 53, the procedure and P as well as the identifier I are registered with the system.
Next, at a step 54, the generated identifier I of the procedure is used as an argument to create a description of an X procedure call for invoking a general-purpose procedure (herein "sqlexec") which activates precompiled database processing. FIG. 3 shows an example of a result of converting an example of FIG. 5 according to the procedure. In this example, two Y descriptions 3 are compiled to create procedures having procedure identifiers 11 and 12, and converted into X general-purpose procedure calls "sqlexec".
Finally, the thus-converted general-purpose procedures "sqlexec" are compiled as X program descriptions by an X compiler at a step 49.
The above operation continues until no element is found in the source file. At last, the operation is returned to the caller at a step 55. When the operation is returned, the general program division of the source file is stored as an object module in a file by the X compiler. The database processing division as well as its source description are registered in a database processing procedure registration area of the system. In addition, information indicating whether an error is detected during compilation is retained.
After that, the operation returns to the step 39. Then, it is determined whether an error is detected during compilation of the source file. If an error is found, all database processing procedures registered so far are invalidated. At a step 42, the procedures are deleted. The whole compilation procedure terminates with an error at a step 43. If no error is found, the operation returns to a step 37. Then, the next source file is handled. If no source file resides, object modules of general program divisions are link-edited at a step 40. If an error is detected in this process, all the database processing procedures are deleted at the step 42. The whole compilation procedure terminates with an error at the step 43. If link editing terminates normally, a sequence of compilation processes terminates normally at a step 44.
Next, an execution system for a thus-compiled database processing program will be explained.
A database processing program starts the operation as a program written and compiled by general X. As execution proceeds, if "sqlexec" is invoked, database processing is carried out based on the logic shown in FIG. 4. That is, "sqlexec" starts execution at a step 57, and retrieves a database processing procedure having a procedure identifier I given as an argument at a step 59. At a step 60, it is determined whether the procedure retrieved is valid. If the procedure is valid, the procedure is executed at a step 61. Then, the operation is returned to the caller. If the procedure has been invalidated for some reason, a source description P pointed to by the I is retrieved from a database processing procedure registration area in the system at a step 62. At a step 63, the P is dynamically recompiled as a Y description to re-create a valid database processing procedure. Then, the I is re-registered as an identifier in the system. The database processing procedure is executed as a step 61.
A registered database processing procedure becomes inoperative and invalid if, for example, the indexes structure of data which the procedure uses is deleted.
The database processing system of the prior art provides the aforesaid operations, posing the problems below.
(1) A database processing program is recompiled many times during debugging, but an executable load module is not created every time. Therefore, identifiers of database processing procedures are consumed extravagantly and used up for a limited period of time. When an attempt is made to cope with this problem, the operation of a database management system becomes complex. Besides, procedures which have already been registered must be deregistered frequently because of errors deriving from other causes. Since a database processing procedure registration area is subject to exclusive control, contention occurs among object-time procedure retrieval, and compile-time procedure registration and deregistration. This causes system performance to deteriorates remarkably. PA0 (2) A registered procedure is assigned a procedure identifier unique to a system under which the procedure is compiled. The procedure identifier of the procedure may be used in another procedure in another system. The procedure, therefore, cannot be executed without any change to its source code. A program written in a conventional general-purpose programming language can be freely transferred between machines of the same type merely by moving load modules. This is not true for database processing programs. To transfer a database processing application program to another system, all source programs must be moved to and recompiled under the system. Thus, it is very difficult to transfer a database processing application program from system to system. PA0 (a) an operating system for managing files and modules by using identifiers, and controlling execution and processing of programs; PA0 (b) a program processor for compiling the first program division and the second program division of the program to create a first module and a second module, and registering the second module by using an identifier which is assigned by the operating system when the first module is registered; and PA0 (c) a program executor for executing the first module, and retrieving the registered second module according to the identifier assigned to the first module for execution while executing the first module. PA0 (a) a first compilation step of compiling the first program division to create a first module; PA0 (b) a second compilation step of compiling the second program division to create a second module, and providing the first module with reference information for referencing the second module with an identifier assigned to the first module; and PA0 (c) an editing step of editing the first module to register it with an operating system, and registering the second module with the operation system so that the second module can be referenced according to the identifier assigned to the first module by the operating system. PA0 (a) a compilation editing step of compiling the first program division to create a module and holding the second program division in the module; or PA0 (b) an execution step of executing a module, and converting the second program division into an executable format for execution while executing the module.